/*
 * THE SOURCE CODES OF THE SOFTWARE ARE VALUABLE ASSETS OF FIDUS TECHNOLOGIES LTD.
 * YOU AGREE TO KEEP ALL SOURCE CODES OF THE SOFTWARE IN CONFIDENCE. YOU MAY NOT TRANSFER
 * OR ASSIGN THE SOFTWARE OR YOUR RIGHTS UNDER THIS AGREEMENT.
 * LIMITED WARRANTY
 * THE SOFTWARE AND ACCOMPANYING WRITTEN MATERIALS (INCLUDING INSTRUCTIONS FOR USE) ARE PROVIDED "AS IS"
 * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU ASSUME THE ENTIRE
 * RISK AS TO THE RESULTS AND PERFORMANCE OF THE SOFTWARE.
 * FIDUS TECHNOLOGIES DOES NOT WARRANT THAT THE SOFTWARE WILL MEET ALL YOUR REQUIREMENTS, THAT OPERATIONS
 * OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ALL SOFTWARE ERRORS WILL BE CORRECTED.
 * FIDUS TECHNOLOGIES-SOFTWARE SOLUTIONS IS NOT RESPONSIBLE FOR PROBLEMS CAUSED BY CHANGES IN THE
 * OPERATING CHARACTERISTICS OF COMPUTER HARDWARE OR COMPUTER OPERATING SYSTEMS WHICH ARE MADE AFTER
 * WHICH ARE MADE AFTER THE RELEASE OF THE SOFTWARE NOR FOR PROBLEMS IN THE INTERACTION OF THE SOFTWARE
 * WITH NON-FIDUS TECHNOLOGIES APPLICATION.WILL HAVE NO RESPONSIBILITY TO REPLACE OR REFUND THE LICENSE FEES
 * FOR MEDIA DAMAGED BY ACCIDENT, ABUSE OR MISAPPLICATION. THIS SOFTWARE IS INTENDED FOR COMMERCIAL,
 * INSTITUTIONAL, AND INDUSTRIAL USERS. THE ABOVE WARRANTIES ARE EXCLUSIVE AND IN LIEU OF ALL OTHER WARRANTIES,
 * WHETHER EXPRESSED OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE AND NON-INFRINGEMENT. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY FIDUS TECHNOLOGIES,
 * ITS EMPLOYEES, DISTRIBUTORS, DEALERS OR AGENTS SHALL INCREASE THE SCOPE OF THE ABOVE WARRANTIES OR
 * CREATE ANY NEW WARRANTIES. NEITHER FIDUS TECHNOLOGIES NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE
 * CREATION, PRODUCTION OR DELIVERY OF THE SOFTWARE SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL
 * OR INCIDENTAL DAMAGES (INCLUDING DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS LOSSES, BUSINESS
 * INTERRUPTION, LOSS OF DATA, AND THE LIKE) ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE,
 * OR ANY OTHER CLAIM BY ANY PARTY EVEN IF FIDUS TECHNOLOGIES HAS BEEN ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGES. IN THE EVENT FIDUS TECHNOLOGIES IS LIABLE FOR ANY DAMAGES, FIDUS TECHNOLOGIES' LIABILITY
 * FOR DAMAGES SHALL BE LIMITED TO THE AMOUNT PAID FOR THE SOFTWARE UNDER THE TERMS AND CONDITIONS OF THIS
 * AGREEMENT.
 * http://www.fidustechnologies.com
 * Copyright(C) 2010 FIDUS TECHNOLOGIES-Software Solutions(R)
 * All rights reserved.
 */

package com.fidus.inventory.beans.customer;

import com.fidus.inventory.beans.images.ImageStore;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Mahesh Kedari<mahesh.kedari@fidustechnologies.com>
 */
@Entity
@Table(name = "Contact_Person_Details_Cust")
@NamedQueries({
    @NamedQuery(name = "ContactPersonDetailsCust.findAll", query = "SELECT c FROM ContactPersonDetailsCust c"),
    @NamedQuery(name = "ContactPersonDetailsCust.findByContactPersonID", query = "SELECT c FROM ContactPersonDetailsCust c WHERE c.contactPersonID = :contactPersonID"),
    @NamedQuery(name = "ContactPersonDetailsCust.findByContactFirstName", query = "SELECT c FROM ContactPersonDetailsCust c WHERE c.contactFirstName = :contactFirstName"),
    @NamedQuery(name = "ContactPersonDetailsCust.findByContactMiddleName", query = "SELECT c FROM ContactPersonDetailsCust c WHERE c.contactMiddleName = :contactMiddleName"),
    @NamedQuery(name = "ContactPersonDetailsCust.findByContactLastName", query = "SELECT c FROM ContactPersonDetailsCust c WHERE c.contactLastName = :contactLastName"),
    @NamedQuery(name = "ContactPersonDetailsCust.findByDescription", query = "SELECT c FROM ContactPersonDetailsCust c WHERE c.description = :description")})
public class ContactPersonDetailsCust implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ContactPerson_ID", nullable = false)
    private Integer contactPersonID;
    @Basic(optional = false)
    @Column(name = "Contact_First_Name", nullable = false, length = 128)
    private String contactFirstName;
    @Column(name = "Contact_Middle_Name", length = 128)
    private String contactMiddleName;
    @Column(name = "Contact_Last_Name", length = 128)
    private String contactLastName;
    @Basic(optional = false)
    @Column(name = "Description", nullable = false, length = 128)
    private String description;
    @JoinColumn(name = "Customer_ID", referencedColumnName = "Customer_ID", nullable = false)
    @ManyToOne(optional = false)
    private CustomerDetails customerDetails;
    @JoinColumn(name = "Contact_Photo", referencedColumnName = "Image_ID")
    @ManyToOne
    private ImageStore imageStore;

    public ContactPersonDetailsCust() {
    }

    public ContactPersonDetailsCust(Integer contactPersonID) {
        this.contactPersonID = contactPersonID;
    }

    public ContactPersonDetailsCust(Integer contactPersonID, String contactFirstName, String description) {
        this.contactPersonID = contactPersonID;
        this.contactFirstName = contactFirstName;
        this.description = description;
    }

    public Integer getContactPersonID() {
        return contactPersonID;
    }

    public void setContactPersonID(Integer contactPersonID) {
        Integer oldContactPersonID = this.contactPersonID;
        this.contactPersonID = contactPersonID;
        changeSupport.firePropertyChange("contactPersonID", oldContactPersonID, contactPersonID);
    }

    public String getContactFirstName() {
        return contactFirstName;
    }

    public void setContactFirstName(String contactFirstName) {
        String oldContactFirstName = this.contactFirstName;
        this.contactFirstName = contactFirstName;
        changeSupport.firePropertyChange("contactFirstName", oldContactFirstName, contactFirstName);
    }

    public String getContactMiddleName() {
        return contactMiddleName;
    }

    public void setContactMiddleName(String contactMiddleName) {
        String oldContactMiddleName = this.contactMiddleName;
        this.contactMiddleName = contactMiddleName;
        changeSupport.firePropertyChange("contactMiddleName", oldContactMiddleName, contactMiddleName);
    }

    public String getContactLastName() {
        return contactLastName;
    }

    public void setContactLastName(String contactLastName) {
        String oldContactLastName = this.contactLastName;
        this.contactLastName = contactLastName;
        changeSupport.firePropertyChange("contactLastName", oldContactLastName, contactLastName);
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        String oldDescription = this.description;
        this.description = description;
        changeSupport.firePropertyChange("description", oldDescription, description);
    }

    public CustomerDetails getCustomerDetails() {
        return customerDetails;
    }

    public void setCustomerDetails(CustomerDetails customerDetails) {
        CustomerDetails oldCustomerDetails = this.customerDetails;
        this.customerDetails = customerDetails;
        changeSupport.firePropertyChange("customerDetails", oldCustomerDetails, customerDetails);
    }

    public ImageStore getImageStore() {
        return imageStore;
    }

    public void setImageStore(ImageStore imageStore) {
        ImageStore oldImageStore = this.imageStore;
        this.imageStore = imageStore;
        changeSupport.firePropertyChange("imageStore", oldImageStore, imageStore);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (contactPersonID != null ? contactPersonID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContactPersonDetailsCust)) {
            return false;
        }
        ContactPersonDetailsCust other = (ContactPersonDetailsCust) object;
        if ((this.contactPersonID == null && other.contactPersonID != null) || (this.contactPersonID != null && !this.contactPersonID.equals(other.contactPersonID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.fidus.inventory.beans.company.ContactPersonDetailsCust[contactPersonID=" + contactPersonID + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
